<template>
  <div class="error-page">
    <div class="error-container">
      <div class="error-header">
        <van-button round type="info" @click="goBack">← 返回</van-button>
        <span class="error-title">页面错误</span>
      </div>
      <van-image
        src="https://img.yzcdn.cn/vant/search.png" 
        width="80"
        height="80"
        class="error-icon"
      />
      <h2 class="error-code">404</h2>
      <h3 class="error-desc">页面未找到</h3>
      <p class="error-text">
        抱歉，您访问的页面不存在或已被移除。<br />
        请检查网址是否正确，或返回首页重新开始。
      </p>
      <div class="btn-group">
        <van-button plain type="primary" @click="goToHome">返回首页</van-button>
        <van-button plain type="info" @click="refreshPage">刷新页面</van-button>
      </div>
      <div class="tips">
        <p>您可以尝试：</p>
        <p>检查网址拼写是否正确</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router';
import { onMounted } from 'vue';

const router = useRouter();

// 返回上一页
const goBack = () => {
  router.go(-1);
};

// 返回首页，假设首页路由是 '/'，可根据实际调整
const goToHome = () => {
  router.push('/');
};

// 刷新当前页面
const refreshPage = () => {
  window.location.reload();
};

onMounted(() => {
  // 也可在这里做一些错误统计、上报等逻辑
});
</script>

<style scoped>
.error-page {
  background: linear-gradient(180deg, #837aff 0%, #b3a8f9 100%);
  min-height: 100vh;
  padding-top: 20px;
  box-sizing: border-box;
}

/* 模拟手机状态栏，和登录页呼应，实际可按需调整或删除 */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  color: #fff;
  font-size: 14px;
}

.error-container {
  width: 85%;
  margin: 30px auto 0;
  text-align: center;
  color: #fff;
}

.error-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.error-title {
  font-size: 16px;
  margin-left: 8px;
}

.error-icon {
  margin-bottom: 15px;
}

.error-code {
  font-size: 36px;
  margin-bottom: 10px;
}

.error-desc {
  font-size: 20px;
  margin-bottom: 20px;
}

.error-text {
  line-height: 1.6;
  margin-bottom: 20px;
}

.btn-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.tips {
  line-height: 1.6;
}
</style>